package com.hulushuju.core.security.ssl;

import javax.net.ssl.X509TrustManager;
import java.security.cert.X509Certificate;

/**
 * @Author: Hanjiafeng
 * @Date: 2019-05-22
 * @Desc: 信任证书管理器工厂类
 */
public class TrustManagerFactory {

    /**
     * 创建信任所有证书对象
     *
     * @return 信任所有证书对象
     */
    public static X509TrustManager createTrustAllManager() {
        return new TrustAllManager();
    }

    /**
     * 信任所有证书管理器
     */
    private static class TrustAllManager implements X509TrustManager {

        @Override
        public void checkClientTrusted(X509Certificate[] x509Certificates, String s) {
        }

        @Override
        public void checkServerTrusted(X509Certificate[] x509Certificates, String s) {
        }

        @Override
        public X509Certificate[] getAcceptedIssuers() {
            return new X509Certificate[0];
        }
    }
}
